<?php
require_once '../../../core/fcCommon.php';
require_once '../../../core/fcORM_raschada_rx.php';

$json = getJsonFromRequest();
$obj = new Entity("raschada_rx_lot");
foreach($json as $key => $value){
    $obj->put($key, $value);
}
$util = new DojoUtil();
$obj->put('drug_lot_date', $util->datetimeFromDojo($obj->get('drug_lot_date')));
$obj->put('create_datetime', date("Y-m-d H:i:s", time() - 3600));
$obj->put('update_datetime', date("Y-m-d H:i:s", time() - 3600));

$conn = new Connection();
$lastId = $conn->persist($obj);

$obj = new Entity("raschada_rx_lot");
$obj->put('drug_lot_id', $lastId);
$res = $conn->find($obj);

$jsonRes = "";
foreach($res as $r){
    $jsonRes = $r->toJson();
    break;
}

echo $jsonRes;
?>